package com.wokeMy.view.Lottery;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Vibrator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.zhongcai.online.R;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.wokeMy.view.adpter.YingkAdapter;
import com.wokeMy.view.base.BaseActivity;
import com.wokeMy.view.model.Constant;
import com.wokeMy.view.model.DoubleLo;
import com.wokeMy.view.model.YkHeData;
import com.wokeMy.view.util.AllSpaceItemDecoration;
import com.wokeMy.view.util.Util;

import org.apache.commons.math3.util.CombinatoricsUtils;
import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Set;

public class YingkActivity extends BaseActivity implements View.OnClickListener{
    RecyclerView yingk_rv,yingk_rv_eth_xia;
    YingkAdapter yingkAdapter,ethyingkAdapter;
    GridLayoutManager gridLayoutManager;
    private ImageView yingkback;
    private RelativeLayout yingktop;
    private TextView issueyingk;
    private ImageView oneyingk;
    private ImageView twoyingk;
    private ImageView treeyingk;
    private LinearLayout saizillyingk,yinghell,yingfasttvll,ethll;
    private TextView betdetailtv;
    private TextView endtimeyingk,endtitleyingk;
    private TextView shakeyingk;
    private TextView bigtvyingk,yingktoptitle,yingjstv,yingfasttvtitle,yingfasttv;
    private RelativeLayout bigrlyingk;
    private TextView smalltvyingk;
    private RelativeLayout smallrlyingk;
    private TextView singletvyingk,doubletvyingk,saizitvyingk,playIntyin;
    private RelativeLayout singlerlyingk;
    private RelativeLayout doublerlyingk;
    private TextView deleteyingktv;
    private TextView zhuyingktv;
    private TextView moneyyingktv;
    private Button yingkok;
    private RelativeLayout yingkbottom;
    Dialog mydialog;
    ArrayList<Integer> data;
    ArrayList<YkHeData> dataModel,xiadataModel;
    YkHeData ykHeData,ykHeDataxia;
    ArrayList<Integer> check,heCheck,sanTonCheck,sanbtChenck,ebCheck,etHeCheck,etHeCheckxia;
    int randomSum,zhuSum;
    int [] filter ={0,0,0,0};
    int[] monen={80,40,25,16,12,10,9,9,10,12,16,25,40,80};
    int[] title={4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    private SensorManager sensorManager;
    private Vibrator vibrator;
    private static final String TAG = "DoubleBallActivity";
    private static final int SENSOR_SHAKE = 10;
    String orderissue;
    ArrayList<String> checkOrder;

    private PopupWindow popupWindow2 = null;//  PopupWindow在android.widget包下，弹出窗口的形式展示。官方文档对该控件的描述是：“一个弹出窗口控件，可以用来显示任意视图(View)，而且会浮动在当前 活动(activity)的顶部”。PopupWindow可以让我们实现多种自定义控件，例如：menu、alertdialog等弹窗似的View
    private LayoutInflater layoutInflater2;//为了获取res 下的layout的xml文件
    private View popView2;

    ArrayList<Integer> popdata;
    ArrayList<YkHeData> popdataModel;
    ArrayList<Integer> popcheck;
    YingkAdapter popyingkAdapter;
    String[] popmonen={"9-80","40-240","15-80","10-440","8"};
    String[] poptitle={"和值","三同号","二同号","三不同号","二不同号"};
    int[] poptitle_hz={4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    int[] popmonen_hz={80,40,25,16,12,10,9,9,10,12,16,25,40,80};
    int[] poptitle_sth={111,222,333,444,555,666};
    int[] popmonen_sth={240,240,240,240,240,240};
    int[] poptitle_sb={1,2,3,4,5,6};
    int[] poptitle_eth={11,22,33,44,55,66};
    int[] poptitle_eth_xia={1,2,3,4,5,6};
    boolean filterSth =false;
     Integer integer;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_yingk);
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    }

    @Override
    public void initView() {
        yingk_rv=myFindViewById(R.id.yingk_rv);
        yingk_rv_eth_xia=myFindViewById(R.id.yingk_rv_eth_xiamian);
        this.yingkbottom = (RelativeLayout) findViewById(R.id.yingk_bottom);
        this.yingkok = (Button) findViewById(R.id.yingk_ok);
        this.moneyyingktv = (TextView) findViewById(R.id.money_yingk_tv);
        this.zhuyingktv = (TextView) findViewById(R.id.zhu_yingk_tv);
        this.deleteyingktv = (TextView) findViewById(R.id.delete_yingk_tv);
        this.doublerlyingk = (RelativeLayout) findViewById(R.id.double_rl_yingk);
        this.singlerlyingk = (RelativeLayout) findViewById(R.id.single_rl_yingk);
        this.singletvyingk = (TextView) findViewById(R.id.single_tv__yingk);
        this.doubletvyingk = (TextView) findViewById(R.id.double_tv_yingk);
        this.saizitvyingk = (TextView) findViewById(R.id.saizi_ll_yingk_tv);
        this.playIntyin = (TextView) findViewById(R.id.playInt_yin);
        this.smallrlyingk = (RelativeLayout) findViewById(R.id.small_rl_yingk);
        this.smalltvyingk = (TextView) findViewById(R.id.small_tv_yingk);
        this.bigrlyingk = (RelativeLayout) findViewById(R.id.big_rl_yingk);
        this.bigtvyingk = (TextView) findViewById(R.id.big_tv_yingk);
        this.shakeyingk = (TextView) findViewById(R.id.shake_yingk);
        this.endtimeyingk = (TextView) findViewById(R.id.endtime_yingk);
        this.endtitleyingk = (TextView) findViewById(R.id.endtimetitle_yingk);
        this.betdetailtv = (TextView) findViewById(R.id.betdetail_tv);
        this.saizillyingk = (LinearLayout) findViewById(R.id.saizi_ll_yingk);
        this.yinghell = (LinearLayout) findViewById(R.id.ying_he_ll);
        this.yingfasttvll = (LinearLayout) findViewById(R.id.ying_fast_tv_ll);
        this.ethll = (LinearLayout) findViewById(R.id.eth_ll);
        this.treeyingk = (ImageView) findViewById(R.id.tree_yingk);
        this.twoyingk = (ImageView) findViewById(R.id.two_yingk);
        this.oneyingk = (ImageView) findViewById(R.id.one_yingk);
        this.issueyingk = (TextView) findViewById(R.id.issue_yingk);
        this.yingktop = (RelativeLayout) findViewById(R.id.yingk_top);
        this.yingkback = (ImageView) findViewById(R.id.yingk_back);
        this.yingktoptitle = (TextView) findViewById(R.id.yingk_title_top);
        this.yingjstv = (TextView) findViewById(R.id.ying_js_tv);
        this.yingfasttvtitle = (TextView) findViewById(R.id.ying_fast_tv_title);
        this.yingfasttv = (TextView) findViewById(R.id.ying_fast_tv);
    }

    @Override
    public void initData() {
        data =new ArrayList<>();
        dataModel =new ArrayList<>();
        xiadataModel=new ArrayList<>();
        check=new ArrayList<>();
        heCheck=new ArrayList<>();
        sanTonCheck =new ArrayList<>();
        sanbtChenck =new ArrayList<>();
        ebCheck =new ArrayList<>();
        etHeCheck =new ArrayList<>();
        etHeCheckxia =new ArrayList<>();
        for (int i = 0; i < poptitle_hz.length; i++) {
            heCheck.add(0);
        }
        for (int i = 0; i < poptitle_sth.length; i++) {
            sanTonCheck.add(0);
        }
        for (int i = 0; i < poptitle_sb.length; i++) {
            sanbtChenck.add(0);
            ebCheck.add(0);
        }
        for (int i = 0; i < poptitle_eth.length; i++) {
            etHeCheck.add(0);
        }
        for (int i = 0; i < monen.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("奖金"+monen[i]+"元");
            dataModel.add(ykHeData);
            data.add(i+4);
            check.add(0);

        }
        for (int i = 0; i < poptitle_eth_xia.length; i++) {
            ykHeDataxia=new YkHeData();
            ykHeDataxia.setNumber(poptitle_eth_xia[i]+"");
            ykHeDataxia.setMoney("");
            xiadataModel.add(ykHeDataxia);
            etHeCheckxia.add(0);
        }
        yingkAdapter=new YingkAdapter(this,dataModel,false);
        ethyingkAdapter=new YingkAdapter(this,xiadataModel,false);
        popdata =new ArrayList<>();
        popdataModel =new ArrayList<>();
        popcheck=new ArrayList<>();

        for (int i = 0; i < popmonen.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(poptitle[i]);
            ykHeData.setMoney("奖金"+popmonen[i]+"元");
            popdataModel.add(ykHeData);
            if (i==0){
                popcheck.add(1);
            }else {
                popcheck.add(0);
            }
        }
        popyingkAdapter=new YingkAdapter(this,popdataModel,true);
        popyingkAdapter.setCheck(popcheck);
//        List<Integer> array = new ArrayList<Integer>();
//        for(int i=3; i<19; i++){
//            array.add(i);
//            System.out.println(i);
//        }
        Set<Integer> _array = Util.filter(data, 7);
        for (Integer str : _array) {
            System.out.println(str);
        }
//        heSearch();
        cptime();
        queryLotteryList();
    }

    @Override
    public void initActivity() {
        gridLayoutManager = new GridLayoutManager(this, 4);
        yingk_rv.setLayoutManager(gridLayoutManager);
        yingk_rv.setAdapter(yingkAdapter);
        yingk_rv.addItemDecoration(new AllSpaceItemDecoration(10));


        yingk_rv_eth_xia.setLayoutManager(new GridLayoutManager(this, 6));
        yingk_rv_eth_xia.setAdapter(ethyingkAdapter);
        yingk_rv_eth_xia.addItemDecoration(new AllSpaceItemDecoration(10));

        bigrlyingk.setOnClickListener(this);
        smallrlyingk.setOnClickListener(this);
        singlerlyingk.setOnClickListener(this);
        doublerlyingk.setOnClickListener(this);
        yingkAdapter.setItemClickListener(new YingkAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                ArrayList<Integer> check = yingkAdapter.getCheck();
                ArrayList<Integer> check1 = ethyingkAdapter.getCheck();
                if (yingktoptitle.getText().toString().trim().equals("二同号")){
                    int checksize=0,check1siz=0;
                    for (int i = 0; i < check1.size(); i++) {
                        if (check.get(i)==1){
                            check1.set(i,0);
                            checksize++;
                        }
                        if (check1.get(i)==1){
                            check1siz++;
                        }
                    }
                    zhuSum=checksize*check1siz;
                    zhuyingktv.setText(zhuSum+"注");
                    moneyyingktv.setText(zhuSum*2+"元");
                    Log.e("setItemClickListener",check1.toString());
                    ethyingkAdapter.setCheck(check1);
                    ethyingkAdapter.notifyDataSetChanged();
                }else {
                    jsZhu(check);
                }


                //和值
                bigtvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                bigtvyingk.setBackgroundResource(R.color.white);
                smalltvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                smalltvyingk.setBackgroundResource(R.color.white);
                singletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                singletvyingk.setBackgroundResource(R.color.white);
                doubletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                doubletvyingk.setBackgroundResource(R.color.white);
                for (int i = 0; i < filter.length; i++) {
                    filter[i]=0;
                }

                //三同号
                filterSth=false;
                yingfasttv.setTextColor(getResources().getColor(R.color.money_yk));
                yingfasttv.setBackgroundResource(R.color.white);
            }
        });

        ethyingkAdapter.setItemClickListener(new YingkAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                ArrayList<Integer> check = yingkAdapter.getCheck();
                ArrayList<Integer> check1 = ethyingkAdapter.getCheck();
                if (yingktoptitle.getText().toString().trim().equals("二同号")){
                    int checksize=0,check1siz=0;
                    for (int i = 0; i < check1.size(); i++) {
                        if (check1.get(i)==1){
                            check.set(i,0);
                            check1siz++;
                        }
                        if (check.get(i)==1){
                            checksize++;
                        }
                    }
                    zhuSum=checksize*check1siz;
                    zhuyingktv.setText(zhuSum+"注");
                    moneyyingktv.setText(zhuSum*2+"元");
                    yingkAdapter.setCheck(check);
                    yingkAdapter.notifyDataSetChanged();
                }
            }
        });
        shakeyingk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                vibrator.vibrate(100);
                Message msg = new Message();
                msg.what = SENSOR_SHAKE;
                handler.sendMessage(msg);

            }
        });
        yingkback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        playIntyin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(YingkActivity.this,PlayIntraActivity.class);
                startActivity(intent);
            }
        });
        deleteyingktv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               inintCheck();
                yingkAdapter.setCheck(check);
                yingkAdapter.notifyDataSetChanged();

                ArrayList<Integer> checkYI=new ArrayList<>();
                for (int i = 0; i < poptitle_eth_xia.length; i++) {
                    checkYI.add(0);
                }
                ethyingkAdapter.setCheck(checkYI);
                ethyingkAdapter.notifyDataSetChanged();
//                jsZhu(check);
                zhuyingktv.setText(0+"注");
                moneyyingktv.setText(0*2+"元");
                filterSth=false;
                yingfasttv.setTextColor(getResources().getColor(R.color.money_yk));
                yingfasttv.setBackgroundResource(R.color.white);

                //和值
                bigtvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                bigtvyingk.setBackgroundResource(R.color.white);
                smalltvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                smalltvyingk.setBackgroundResource(R.color.white);
                singletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                singletvyingk.setBackgroundResource(R.color.white);
                doubletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                doubletvyingk.setBackgroundResource(R.color.white);
                for (int i = 0; i < filter.length; i++) {
                    filter[i]=0;
                }

            }
        });
        yingkok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               String title=yingktoptitle.getText().toString().trim();
                checkOrder=new ArrayList<>();
                ArrayList<Integer> check = yingkAdapter.getCheck();
                for (int i = 0; i < check.size(); i++) {
                    if (check.get(i)==1){
                        if (title.equals("二同号")){
                            for (int i1 = 0; i1 < dataModel.get(i).getNumber().length(); i1++) {
                                checkOrder.add(""+dataModel.get(i).getNumber().charAt(i1));
                            }
                        }else {
                            checkOrder.add(dataModel.get(i).getNumber());
                        }
                    }
                }
                switch (title) {
                    case "三同号":
                        if (filterSth){
                            checkOrder.add("111 222 333 444 555 666");
                        }
                        if (zhuSum>1){
                            tishi(title+"最多选一注");
                        }
                        break;
                    case "三不同号":
                        if (filterSth){
                            checkOrder.add("123 234 345 456");
                        }
                        if (zhuSum>1){
                            tishi(title+"最多选一注");
                            return;
                        }
                        break;
                    case "二不同号":
                        if (zhuSum>2){
                            tishi(title+"最多选一注");
                            return;
                        }
                        break;
                    case "二同号":
                        String trim = zhuyingktv.getText().toString().trim();
                        zhuSum=Integer.valueOf(trim.substring(0,trim.length()-1));
                        Log.e("二同号",zhuSum+"");
                        if (zhuSum>1){
                            tishi(title+"最多选一注");
                            return;
                        }
                        ArrayList<Integer> check1 = ethyingkAdapter.getCheck();
                        for (int i = 0; i < check1.size(); i++) {
                            if (check1.get(i)==1){
                                checkOrder.add(poptitle_eth_xia[i]+"");
                            }
                        }
                        break;
                    default:
                        break;
                }

                if (checkOrder.size()<1){
                    tishi("请选择至少一注");
                } else {
                    Intent intent=new Intent(YingkActivity.this,YingkTicketActivity.class);
                    intent.putExtra("blueBall",checkOrder);
                    intent.putExtra("orderissue",orderissue);
                    intent.putExtra("zhuTv", zhuyingktv.getText().toString().trim());
                    intent.putExtra("monTv", moneyyingktv.getText().toString().trim());
                    intent.putExtra("lotteryid", "123");
                    intent.putExtra("type",yingktoptitle.getText().toString().trim());
                    startActivity(intent);
                }

            }
        });
        yingktoptitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showSelect(yingktop);
            }
        });
        yingfasttv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                filterSth=!filterSth;
                if (filterSth){
                    check.clear();
                    for (int i = 0; i < title.length; i++) {
                        check.add(0);
                    }
                    yingkAdapter.setCheck(check);
                    yingkAdapter.notifyDataSetChanged();
                    yingfasttv.setTextColor(getResources().getColor(R.color.white));
                    yingfasttv.setBackgroundResource(R.color.green_yk);
                    zhuyingktv.setText(1+"注");
                    moneyyingktv.setText(2+"元");
                }else {
                    zhuyingktv.setText(0+"注");
                    moneyyingktv.setText(0+"元");
                    yingfasttv.setTextColor(getResources().getColor(R.color.money_yk));
                    yingfasttv.setBackgroundResource(R.color.white);
                }
            }
        });
    }

    @Override
    public void onClick(View v) {
        int type=1;
        switch (v.getId()) {
            case R.id.big_rl_yingk:
                //2 大 3小 单 5 双 7
                if (filter[0]==0){
                    filter[0]=1;//变成选中状态
                    type=type*2;
                    bigtvyingk.setTextColor(getResources().getColor(R.color.white));
                    bigtvyingk.setBackgroundResource(R.color.green_yk);
                    //判断小的 filter
                    if (filter[1]==1){
                        //小已经选中
                        smalltvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                        smalltvyingk.setBackgroundResource(R.color.white);
                        filter[1]=0;
                    }
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        type=type*5;
                    }

                    //判断双的 filter
                    if (filter[3]==1){
                        //双已经选中
                        type=type*7;
                    }
                }else {
                    filter[0]=0;
                    bigtvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                    bigtvyingk.setBackgroundResource(R.color.white);
                    //未选中状态
                    //判断小的 filter
                    if (filter[1]==1){
                        //小已经选中
                        type=type*3;
                    }
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        type=type*5;
                    }

                    //判断双的 filter
                    if (filter[3]==1){
                        //双已经选中
                        type=type*7;
                    }
                }
                break;
            case R.id.small_rl_yingk:
                //2 大 3小 单 5 双 7
                if (filter[1]==0){
                    filter[1]=1;//变成选中状态
                    type=type*3;
                    smalltvyingk.setTextColor(getResources().getColor(R.color.white));
                    smalltvyingk.setBackgroundResource(R.color.green_yk);
                    //判断大的 filter
                    if (filter[0]==1){
                        //大已经选中
                        bigtvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                        bigtvyingk.setBackgroundResource(R.color.white);
                        filter[0]=0;
                    }
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        type=type*5;
                    }

                    //判断双的 filter
                    if (filter[3]==1){
                        //双已经选中
                        type=type*7;
                    }
                }else {
                    filter[1]=0;
                    smalltvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                    smalltvyingk.setBackgroundResource(R.color.white);
                    //未选中状态
                    //判断小的 filter
                    if (filter[0]==1){
                        //小已经选中
                        type=type*2;
                    }
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        type=type*5;
                    }
                    //判断双的 filter
                    if (filter[3]==1){
                        //双已经选中
                        type=type*7;
                    }
                }
                break;
            case R.id.single_rl_yingk:
                //2 大 3小 单 5 双 7
                if (filter[2]==0){
                    filter[2]=1;//变成选中状态
                    type=type*5;
                    singletvyingk.setTextColor(getResources().getColor(R.color.white));
                    singletvyingk.setBackgroundResource(R.color.green_yk);
                    //判断双的 filter
                    if (filter[3]==1){
                        //小已经选中
                        doubletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                        doubletvyingk.setBackgroundResource(R.color.white);
                        filter[3]=0;
                    }
                    //判断大的 filter
                    if (filter[0]==1){
                        //大已经选中
                        type=type*2;
                    }

                    //判断小的 filter
                    if (filter[1]==1){
                        //双已经选中
                        type=type*3;
                    }
                }else {
                    filter[2]=0;
                    singletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                    singletvyingk.setBackgroundResource(R.color.white);
                    //未选中状态
                    //判断小的 filter
                    if (filter[3]==1){
                        //小已经选中
                        type=type*5;
                    }
                    //判断大的 filter
                    if (filter[0]==1){
                        //大已经选中
                        type=type*2;
                    }
                    //判断小的 filter
                    if (filter[1]==1){
                        //小已经选中
                        type=type*3;
                    }
                }
                break;
            case R.id.double_rl_yingk:
                //2 大 3小 单 5 双 7
                if (filter[3]==0){
                    filter[3]=1;//变成选中状态
                    type=type*7;
                    doubletvyingk.setTextColor(getResources().getColor(R.color.white));
                    doubletvyingk.setBackgroundResource(R.color.green_yk);
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        singletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                        singletvyingk.setBackgroundResource(R.color.white);
                        filter[2]=0;
                    }
                    //判断大的 filter
                    if (filter[0]==1){
                        //大已经选中
                        type=type*2;
                    }
                    //判断小的 filter
                    if (filter[1]==1){
                        //双已经选中
                        type=type*3;
                    }
                }else {
                    filter[3]=0;
                    doubletvyingk.setTextColor(getResources().getColor(R.color.money_yk));
                    doubletvyingk.setBackgroundResource(R.color.white);
                    //未选中状态
                    //判断单的 filter
                    if (filter[2]==1){
                        //单已经选中
                        type=type*5;
                    }
                    //判断大的 filter
                    if (filter[0]==1){
                        //大已经选中
                        type=type*2;
                    }

                    //判断小的 filter
                    if (filter[1]==1){
                        //小已经选中
                        type=type*3;
                    }
                }
                break;
            default:
                break;
        }
        check.clear();
        for (int i = 0; i < 16; i++) {
            check.add(0);
        }
        Log.e("check",""+check.toString());
        Log.e("type",""+type);
        if (type!=1){
            Set<Integer> _array = Util.filter(data, type);
            for (Integer str : _array) {
                System.out.println(str);
                Log.e("Util.filter",str+"");
                check.set(str,1);
            }
        }
        Log.e("Util.filter",""+check.toString());
        yingkAdapter.setCheck(check);
        yingkAdapter.notifyDataSetChanged();
        jsZhu(check);
    }
       void inintCheck(){
           check.clear();
           for (int i = 0; i < 16; i++) {
               check.add(0);
           }
        }
    void inintCheck(int size){
        check.clear();
        for (int i = 0; i < size; i++) {
            check.add(0);
        }
    }
    /**
     *
     * 动作执行
     */
    Handler handler = new Handler(Looper.getMainLooper()) {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case SENSOR_SHAKE:
                    Log.i(TAG, "检测到摇晃，执行操作！");

                    randomSum=0;
                   // "和值","三同号","二同号","三不同号","二不同号"
                    String trim = yingktoptitle.getText().toString().trim();
                    int  length=6,chishu=3;
                    int checkLen=popmonen_hz.length;
                    ArrayList<String> randomaa;
                    ArrayList<Integer> checkxia=new ArrayList<>();
                    for (int i = 0; i < poptitle_eth_xia.length; i++) {
                        checkxia.add(0);
                    }
                    switch (trim) {
                        case "和值":
                            length=6;
                            chishu=3;
                            checkLen=popmonen_hz.length;
                            randomaa = Util.createRandom(length, chishu);
                            for (int i = 0; i < randomaa.size(); i++) {
                                randomSum=randomSum+Integer.parseInt(randomaa.get(i));
                            }
                            Log.e("randomaa",randomSum+"");
                            inintCheck(checkLen);
                            check.set(randomSum,1);
                            break;
                        case "三同号":
                            length=6;
                            chishu=1;
                            checkLen=popmonen_sth.length;
                            randomaa = Util.createRandom(length, chishu);
                            for (int i = 0; i < randomaa.size(); i++) {
                                randomSum=randomSum+Integer.parseInt(randomaa.get(i));
                            }
                            Log.e("randomaa",randomSum+"");
                            inintCheck(checkLen);
                            check.set(randomSum,1);

                            //三同号
                            filterSth=false;
                            yingfasttv.setTextColor(getResources().getColor(R.color.money_yk));
                            yingfasttv.setBackgroundResource(R.color.white);
                            break;
                        case "三不同号":
                            length=6;
                            chishu=3;
                            checkLen=poptitle_sb.length;
                            randomaa = Util.createRandom(length, chishu);
                            Log.e("三不同号",randomaa.toString());
                            inintCheck(checkLen);
                            Log.e("inintCheck",check.toString());
                            for (int i = 0; i < randomaa.size(); i++) {
                                check.set(Integer.valueOf(randomaa.get(i)),1);
                            }
                            Log.e("inintCheck随机设置后",check.toString());
                            break;
                        case "二不同号":
                            length=6;
                            chishu=2;
                            checkLen=poptitle_sb.length;
                            randomaa = Util.createRandom(length, chishu);
                            inintCheck(checkLen);
                            for (int i = 0; i < randomaa.size(); i++) {
                                check.set(Integer.valueOf(randomaa.get(i)),1);
                            }
                            break;
                        case "二同号":
                            length=6;
                            chishu=2;
                            checkLen=poptitle_sb.length;
                            randomaa = Util.createRandom(length, chishu);
                            inintCheck(checkLen);
                            for (int i = 0; i < randomaa.size(); i++) {
                                if (i==0){
                                    check.set(Integer.valueOf(randomaa.get(i)),1);
                                }else {
                                    checkxia.set(Integer.valueOf(randomaa.get(i)),1);
                                }
                            }
                            break;
                        default:
                            length=6;
                            chishu=3;
                            checkLen=popmonen_hz.length;
                            randomaa = Util.createRandom(length, chishu);
                            for (int i = 0; i < randomaa.size(); i++) {
                                randomSum=randomSum+Integer.parseInt(randomaa.get(i));
                            }
                            Log.e("randomaa",randomSum+"");
                            inintCheck(checkLen);
                            check.set(randomSum,1);
                            break;
                    }
                    yingkAdapter.setCheck(check);
                    yingkAdapter.notifyDataSetChanged();
                    ethyingkAdapter.setCheck(checkxia);
                    ethyingkAdapter.notifyDataSetChanged();
                    if (trim.equals("二同号")){
                        zhuyingktv.setText(1+"注");
                        moneyyingktv.setText(2+"元");
                    }else {
                        jsZhu(check);
                    }

                    break;
            }
        }

    };

    @Override
    protected void onResume() {
        super.onResume();
        if (sensorManager != null) {// 注册监听器
            sensorManager.registerListener(sensorEventListener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
            // 第一个参数是Listener，第二个参数是所得传感器类型，第三个参数值获取传感器信息的频率
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (sensorManager != null) {// 取消监听器
            sensorManager.unregisterListener(sensorEventListener);
        }
    }

    /**
     * 重力感应监听
     */
    private SensorEventListener sensorEventListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {

            // 传感器信息改变时执行该方法
            float[] values = event.values;
            float x = values[0]; // x轴方向的重力加速度，向右为正
            float y = values[1]; // y轴方向的重力加速度，向前为正
            float z = values[2]; // z轴方向的重力加速度，向上为正
            Log.i("DoubleBallActivity", "x轴方向的重力加速度" + x +  "；y轴方向的重力加速度" + y +  "；z轴方向的重力加速度" + z);
            // 一般在这三个方向的重力加速度达到40就达到了摇晃手机的状态。
            int medumValue = 19;// 如果不敏感请自行调低该数值,低于10的话就不行了,因为z轴上的加速度本身就已经达到10了
            if (Math.abs(x) > medumValue || Math.abs(y) > medumValue || Math.abs(z) > medumValue) {
                if (!fastClickNoToast()){
                    vibrator.vibrate(200);
                    Message msg = new Message();
                    msg.what = SENSOR_SHAKE;
                    handler.sendMessage(msg);
                }else {
                    //                        Toast.makeText(DoubleBallActivity.this, "请勿重复摇晃，！", Toast.LENGTH_SHORT).show();
                }
            }

        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {

        }
    };
    void jsZhu(ArrayList<Integer> data){
        zhuSum=0;
        Log.e("jsZhu",data.toString());
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i)==1){
                zhuSum++;
            }
        }
        if (yingktoptitle.getText().toString().equals("三不同号")){
            if (zhuSum>2){
                zhuSum=(int) CombinatoricsUtils.binomialCoefficient(zhuSum, 3);
            }else {
                zhuSum=0;
            }
        }else if (yingktoptitle.getText().toString().equals("二不同号")){
            if (zhuSum>1){
                zhuSum=(int) CombinatoricsUtils.binomialCoefficient(zhuSum, 2);
            }else {
                zhuSum=0;
            }
        }
        Log.e("jsZhu",zhuSum+"");
        zhuyingktv.setText(zhuSum+"注");
        moneyyingktv.setText(zhuSum*2+"元");
    }
    // 和数及奖金（目前只有高频彩
    public void  heSearch(){
        AsyncHttpClient ahc = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("lotteryid","123");//彩票ID 118//双色球 106 大乐透 123 和值
        Log.e("和数及奖金（目前只有高频彩", Constant.CPHZ_URL);
        Log.e("和数及奖金（目前只有高频彩params",params.toString());
        //url:   parmas：请求时携带的参数信息   responseHandler：是一个匿名内部类接受成功过失败
        ahc.post(Constant.CPHZ_URL, params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                String result = null;
                try {
                    result = new String(bytes, "utf-8");
                    //                        Toast.makeText(SeletCardActivity.this, result, Toast.LENGTH_SHORT).show();
                    Log.e("和数及奖金（目前只有高频彩result", result);
                    try {
                        Util.closeDialog(mydialog);
                        JSONObject jsonObject =new JSONObject(result);
                        if (jsonObject.get("flag").equals("success")) {
//                            Gson gson = new Gson();
//                            JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("data");
//                            for (int i1 = 0; i1 < jsonArray.length(); i1++) {
//                                DoubleLo doubleLo = gson.fromJson(jsonArray.getString(i1), DoubleLo.class);
//                                // status -1新奖期可预售 0新奖期开期通知 2奖期期结通知  3奖期开始开奖通知 7奖期开奖完成通知
//                                data.add(doubleLo);
//                            }
//                            Log.e("doubleLo.getStatus()",""+data.toString());
//
                        } else {
                            String info = jsonObject.getString("info");
                            if (jsonObject.has("data")){
                                info=jsonObject.getJSONObject("data").getJSONObject("data").getString("dealmsg");
                            }
                            tishi(info);
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

            }
            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                closeLoadDial(mydialog);
            }
        });
    }

    // 获取奖期倒计时
    public void  cptime(){
        AsyncHttpClient ahc = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("lotteryid","123");
        //        params.put("issue",""); //奖期，不传默认最新一期
        Log.e("获取奖期倒计时", Constant.CPENDTIME_URL);
        Log.e("获取奖期倒计时",params.toString());
        //url:   parmas：请求时携带的参数信息   responseHandler：是一个匿名内部类接受成功过失败
        ahc.post(Constant.CPENDTIME_URL, params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                String result = null;
                try {
                    result = new String(bytes, "utf-8");
                    //                        Toast.makeText(SeletCardActivity.this, result, Toast.LENGTH_SHORT).show();
                    Log.e("获取奖期倒计时result", result);
                    try {
                        Util.closeDialog(mydialog);
                        JSONObject jsonObject =new JSONObject(result);
                        if (jsonObject.get("flag").equals("success")) {
                            String issue = jsonObject.getJSONObject("data").getJSONObject("data").getString("issue");
                            String endtime = jsonObject.getJSONObject("data").getJSONObject("data").getString("endtime");
                             integer = Integer.valueOf(endtime);
                            CountDownTimer timer = new CountDownTimer(integer*1000, 1000) {
                                @Override
                                public void onTick(long millisUntilFinished) {
                                    // TODO Auto-generated method stub
                                    if ((millisUntilFinished/1000)==420){
                                        this.cancel();
                                        mydialog=Util.createLoadingDialog(YingkActivity.this);
                                        cptime();
                                    }
                                    String qianS,houS;
                                    int qian = (int) ((millisUntilFinished/1000) / 60);
                                    int hou = (int) ((millisUntilFinished/1000) %60);
                                    if (qian<10){
                                        qianS="0"+qian;
                                    }else {
                                        qianS=""+qian;
                                    }
                                    if (hou<10){
                                        houS="0"+hou;
                                    }else {
                                        houS=""+hou;
                                    }
                                    endtimeyingk.setText(qianS+":"+houS);
                                }
                                @Override
                                public void onFinish() {
//                                    integer=600;
//                                    cptime();
                                    endtimeyingk.setText("00"+":"+"00");
                                }
                            }.start();
                            endtitleyingk.setText("距"+issue.substring(issue.length()-2,issue.length())+"期截止");
                            /** 倒计时60秒，一次1秒 */


                        } else {
                            String info = jsonObject.getString("info");
                            if (jsonObject.has("data")){
                                info=jsonObject.getJSONObject("data").getJSONObject("data").getString("dealmsg");
                            }
                            tishi(info);
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

            }
            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                closeLoadDial(mydialog);
            }
        });
    }
    // 查询奖期列表
    public void  queryLotteryList(){
        AsyncHttpClient ahc = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("lotteryid","123");//玩法代码 118//双色球 106 大乐透 123 赢快3
        Log.e("查询奖期列表params",params.toString());
        //url:   parmas：请求时携带的参数信息   responseHandler：是一个匿名内部类接受成功过失败
        ahc.post(Constant.CPLIST_URL, params, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                closeLoadDial(mydialog);
                String result = null;
                try {
                    result = new String(bytes, "utf-8");
                    //                        Toast.makeText(SeletCardActivity.this, result, Toast.LENGTH_SHORT).show();
                    Log.e("查询奖期列表result", result);
                    try {
                        JSONObject jsonObject =new JSONObject(result);
                        if (jsonObject.get("flag").equals("success")) {
                            Gson gson = new Gson();
                            JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("data");
                            DoubleLo doubleLo1 = gson.fromJson(jsonArray.getString(0), DoubleLo.class);
                            orderissue=doubleLo1.getIssue();
                            if (jsonArray.length()>1){
                                DoubleLo doubleLo = gson.fromJson(jsonArray.getString(1), DoubleLo.class);
                                if (!TextUtils.isEmpty(doubleLo.getBonuscode())){
                                    saizitvyingk.setVisibility(View.GONE);
                                    saizillyingk.setVisibility(View.VISIBLE);
                                    final ArrayList<String> strings = Util.dealtIssueGg(doubleLo.getBonuscode());
                                    StringBuffer tip =new StringBuffer();
                                    for (int i1 = 0; i1 < strings.size(); i1++) {
                                        switch (i1) {
                                            case 0:
                                                initList(strings.get(i1),oneyingk);
                                                tip.append(strings.get(i1)+" ");
                                                break;
                                            case 1:
                                                initList(strings.get(i1),twoyingk);
                                                tip.append(strings.get(i1)+" ");
                                                break;
                                            case 2:
                                                initList(strings.get(i1),treeyingk);
                                                tip.append(strings.get(i1));
                                                break;
                                            default:
                                                initList(strings.get(i1),oneyingk);
                                                break;
                                        }
                                    }
                                    issueyingk.setText(doubleLo.getIssue().substring(doubleLo.getIssue().length()-2,doubleLo.getIssue().length())+"期开奖："+tip.toString());
                                }
                            }

                        } else {
                            String info = jsonObject.getString("info");
                            if (jsonObject.has("data")){
                                info=jsonObject.getJSONObject("data").getJSONObject("data").getString("dealmsg");
                            }
                            tishi(info);
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

            }
            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                closeLoadDial(mydialog);
            }
        });
    }
    void initList(String s,ImageView imageView){
        switch (s) {
            case "1":
                imageView.setBackgroundResource(R.mipmap.one_dice);
                break;
            case "2":
                imageView.setBackgroundResource(R.mipmap.two_dice);
                break;
            case "3":
                imageView.setBackgroundResource(R.mipmap.three_dice);
                break;
            case "4":
                imageView.setBackgroundResource(R.mipmap.four_dice);
                break;
            case "5":
                imageView.setBackgroundResource(R.mipmap.five_dice);
                break;
            case "6":
                imageView.setBackgroundResource(R.mipmap.six_dice);
                break;
            default:
                imageView.setBackgroundResource(R.mipmap.one_dice);
                break;
        }
    }

    public void showSelect(View anchor) {//anchor 想让该弹出框在那个组件下显示 就传哪个组件
        Rect frame = new Rect();
        getWindow().getDecorView()
                .getWindowVisibleDisplayFrame(frame);
        int i = 0;
        int j = 0;
        int[] location = { i, j };
        anchor.getLocationOnScreen(location);
        layoutInflater2 = LayoutInflater.from(this);
        popView2 = layoutInflater2.inflate(R.layout.layout_pop_yingkuai, null);
        popView2.setFocusableInTouchMode(true);
        popView2.setFocusable(true);
        RecyclerView pop_rv = (RecyclerView) popView2
                .findViewById(R.id.yl_pop_rv);
        pop_rv.setLayoutManager(new GridLayoutManager(this,3));
        pop_rv.setAdapter(popyingkAdapter);
        pop_rv.addItemDecoration(new AllSpaceItemDecoration(20));
//        layMScan.setOnClickListener(this);
        popupWindow2 = new PopupWindow(popView2,
                ViewGroup.LayoutParams.MATCH_PARENT/*
                                                                 * DipPxUtil.dip2px
                                                                * (context,
                                                                 * 126)
                                                                 */,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT, true);
        //产生背景变暗效果
        WindowManager.LayoutParams lp =getWindow().getAttributes();
        lp.alpha = 1f;
        getWindow().setAttributes(lp);
        ColorDrawable dw = new ColorDrawable(999999);
        popupWindow2.setBackgroundDrawable(dw); //如果不设置PopupWindow的背景，无论是点击外部区域还是Back键都无法dismiss弹框
        popupWindow2.setFocusable(true);
        popupWindow2.setOutsideTouchable(true);//点击弹出框外任意一区域弹出框消失
        popupWindow2.update();
        popupWindow2.showAsDropDown(anchor, 0, 0);
        //设置popupWindow消失时的监听
        popupWindow2.setOnDismissListener(new PopupWindow.OnDismissListener() {
            //在dismiss中恢复透明度
            public void onDismiss() {
                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1f;
               getWindow().setAttributes(lp);
            }
        });
        popyingkAdapter.setItemClickListener(new YingkAdapter.MyItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                //"和值","三同号","二同号","三不同号","二不同号"
                String title = yingktoptitle.getText().toString().trim();
                switch (position) {
                    case 0:
                        if (!title.equals("和值")){
                            yingktoptitle.setText(poptitle[position]);
                            popupWindow2.dismiss();
                            initHz();
                        }else {
                            popupWindow2.dismiss();
                        }

                        break;
                    case 1:
                        if (!title.equals("三同号")){
                            yingktoptitle.setText(poptitle[position]);
                            popupWindow2.dismiss();
                            initSth();
                        }else {
                            popupWindow2.dismiss();
                        }
                        break;
                    case 3:
                        if (!title.equals("三不同号")){
                            yingktoptitle.setText(poptitle[position]);
                            popupWindow2.dismiss();
                            initSbt();
                        }else {
                            popupWindow2.dismiss();
                        }
                        break;
                    case 4:
                        if (!title.equals("二不同号")){
                            yingktoptitle.setText(poptitle[position]);
                            popupWindow2.dismiss();
                            initEbt();
                        }else {
                            popupWindow2.dismiss();
                        }
                        break;
                    case 2:
                        if (!title.equals("二同号")){
                            yingktoptitle.setText(poptitle[position]);
                            popupWindow2.dismiss();
                            initETh();
                        }else {
                            popupWindow2.dismiss();
                        }
                        break;
                    default:
                        tishiToast("暂未开通，敬请期待。");
                        break;
                }
                jsZhu(yingkAdapter.getCheck());
            }
        });
    }
    void initHz(){
        gridLayoutManager.setSpanCount(4);
        title=null;
        monen=null;
        dataModel.clear();
        data.clear();//过虑数据
        title=poptitle_hz;
        monen=popmonen_hz;
        for (int i = 0; i < monen.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("奖金"+monen[i]+"元");
            dataModel.add(ykHeData);
            data.add(title[i]);
        }
//        Log.e("保存三同号的状态",yingkAdapter.getCheck().toString());
//        sanTonCheck=null;
//        sanTonCheck=new ArrayList<>();
//        sanTonCheck.addAll(yingkAdapter.getCheck()); //保存三同号 状态
//        Log.e("保存三同号的状态sanbuTonCheck",sanTonCheck.toString());
        yingkAdapter.setSigle(false);
        yingkAdapter.setCheck(heCheck);
        Log.e("yingkAdaptersth",yingkAdapter.getCheck().toString());
        yingkAdapter.notifyDataSetChanged();
        yingjstv.setText("猜开奖号码相加的和");
        yingfasttvtitle.setText("快速选号");
        yinghell.setVisibility(View.VISIBLE);
        yingfasttvll.setVisibility(View.GONE);
        yingfasttvtitle.setVisibility(View.VISIBLE);
        ethll.setVisibility(View.GONE);
        yingk_rv_eth_xia.setVisibility(View.GONE);
    }
    void initSth(){
        gridLayoutManager.setSpanCount(4);
        title=null;
        monen=null;
        dataModel.clear();
        title=poptitle_sth;
        monen=popmonen_sth;
        for (int i = 0; i < monen.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("奖金"+monen[i]+"元");
            dataModel.add(ykHeData);
        }
//        Log.e("保存和值的状态",yingkAdapter.getCheck().toString());
//        heCheck=null;
//        heCheck=new ArrayList<>();
//        heCheck.addAll(yingkAdapter.getCheck()); //保存状态
//        Log.e("保存和值的状态heCheck",heCheck.toString());
        yingkAdapter.setCheck(sanTonCheck);
        yingkAdapter.setSigle(true);
        Log.e("yingkAdaptersth",yingkAdapter.getCheck().toString());
        yingkAdapter.notifyDataSetChanged();
        yingjstv.setText("猜豹子(3个同号)");
        yingfasttvtitle.setText("任意一个豹子开出即中奖,奖金40元");
        yinghell.setVisibility(View.GONE);
        yingfasttvll.setVisibility(View.VISIBLE);
        yingfasttvtitle.setVisibility(View.VISIBLE);
        ethll.setVisibility(View.GONE);
        yingk_rv_eth_xia.setVisibility(View.GONE);
        yingfasttv.setText("三同号通选");
    }
    void initSbt(){
        gridLayoutManager.setSpanCount(3);
        title=null;
        monen=null;
        dataModel.clear();
        title=poptitle_sb;
        for (int i = 0; i < title.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("");
            dataModel.add(ykHeData);
        }
        //        Log.e("保存和值的状态",yingkAdapter.getCheck().toString());
        //        heCheck=null;
        //        heCheck=new ArrayList<>();
        //        heCheck.addAll(yingkAdapter.getCheck()); //保存状态
        //        Log.e("保存和值的状态heCheck",heCheck.toString());
        yingkAdapter.setCheck(sanbtChenck);
        yingkAdapter.setSigle(false);
        Log.e("yingkAdaptersth",yingkAdapter.getCheck().toString());
        yingkAdapter.notifyDataSetChanged();
        yingjstv.setText("猜3个不同号码，奖金40元");
        yingfasttvtitle.setText("任意一组三连号开出即中奖，奖金10元");
        yinghell.setVisibility(View.GONE);
        yingfasttvll.setVisibility(View.VISIBLE);
        yingfasttvtitle.setVisibility(View.VISIBLE);
        ethll.setVisibility(View.GONE);
        yingk_rv_eth_xia.setVisibility(View.GONE);
        yingfasttv.setText("三连号通选");
    }
    void initEbt(){
        gridLayoutManager.setSpanCount(3);
        title=null;
        monen=null;
        dataModel.clear();
        title=poptitle_sb;
        for (int i = 0; i < title.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("");
            dataModel.add(ykHeData);
        }
        //        Log.e("保存和值的状态",yingkAdapter.getCheck().toString());
        //        heCheck=null;
        //        heCheck=new ArrayList<>();
        //        heCheck.addAll(yingkAdapter.getCheck()); //保存状态
        //        Log.e("保存和值的状态heCheck",heCheck.toString());
        yingkAdapter.setCheck(ebCheck);
        yingkAdapter.setSigle(false);
        Log.e("yingkAdaptersth",yingkAdapter.getCheck().toString());
        yingkAdapter.notifyDataSetChanged();
        yingjstv.setText("选2个不同的号码，奖金8元");
        yinghell.setVisibility(View.GONE);
        yingfasttvll.setVisibility(View.GONE);
        yingfasttvtitle.setVisibility(View.GONE);
        ethll.setVisibility(View.GONE);
        yingk_rv_eth_xia.setVisibility(View.GONE);
    }
    void initETh(){
        gridLayoutManager.setSpanCount(6);
        title=null;
        monen=null;
        dataModel.clear();
        title=poptitle_eth;
        for (int i = 0; i < title.length; i++) {
            ykHeData=new YkHeData();
            ykHeData.setNumber(title[i]+"");
            ykHeData.setMoney("");
            dataModel.add(ykHeData);
        }
        //        Log.e("保存和值的状态",yingkAdapter.getCheck().toString());
        //        heCheck=null;
        //        heCheck=new ArrayList<>();
        //        heCheck.addAll(yingkAdapter.getCheck()); //保存状态
        //        Log.e("保存和值的状态heCheck",heCheck.toString());
        yingkAdapter.setCheck(etHeCheck);
        yingkAdapter.setSigle(false);
        Log.e("yingkAdaptersth",yingkAdapter.getCheck().toString());
        yingkAdapter.notifyDataSetChanged();
        yingjstv.setText("猜对子(2个号相同)");
        yingfasttvtitle.setText("不同号");
        yinghell.setVisibility(View.GONE);
        yingfasttvll.setVisibility(View.GONE);
        yingfasttvtitle.setVisibility(View.VISIBLE);
        ethll.setVisibility(View.VISIBLE);


        yingk_rv_eth_xia.setVisibility(View.VISIBLE);
    }
}
